#include "stdio.h"
#include "unistd.h"
#include "sys/types.h"
#include "sys/stat.h"
#include "fcntl.h"
#include "stdlib.h"
#include "string.h"
#include "sys/ioctl.h"


int main(int argc, char *argv[]){
	int fd;
	int ret;
	unsigned char data;
	char *filename;

	if (argc != 2) {
		printf("Error Usage!\r\n");
		return -1;
	}
	
	filename = argv[1];
	fd = open(filename, O_RDWR);
	if(fd < 0) {
		printf("file %s open failed\r\n",argv[1]);
		return -1;
	}

	while (1)
	{
		ret = read(fd, &data, sizeof(data));
		if (ret<0)
		{
				
		}else{
			if(data){
				printf("keyvalue = %#X\r\n", data);
			}
		}
		
	}

	ret = close(fd);  // close文件
	if(ret <0){
		printf("file %s close failed\r\n",argv[1]);
		return -1;
	}

	return 0;
}
